﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SoldierChaseState : ISoldierState {
    public SoldierChaseState(SoldierFSMSystem fsm,Character character) : base(fsm,character)
    {
        m_stateID = SoldierStateID.Chase;
    }

    public override void Act(List<Character> targets)
    {
        if (targets == null || targets.Count > 0) return;
        m_character.MoveTo(targets[0].Position);
             
    }

    public override void Reason(List<Character> targets)
    {
        if (targets == null || targets.Count == 0)
        {
            m_FSM.PerformTransition(SoldierTrasition.LostEnemy);
            return;
        }
        if (targets.Count > 0)
        {
            float disctance = Vector3.Distance(targets[0].Position, m_character.Position);
            if (m_character.AttackRange >= disctance)
            {
                //在攻击范围
                m_FSM.PerformTransition(SoldierTrasition.InAttackDistance);
            }
        }
    }

    
}
